from typing import Any

from aiogram import types
from aiogram_dialog import DialogManager

from src.application.user.service import UserService


async def set_user_language(call: types.CallbackQuery, widget: Any, manager: DialogManager):
    user_service: UserService = manager.middleware_data.get("user_service")
    await user_service.change_user_lang(call.from_user.id, widget.widget_id)
    await call.answer("Language changed")

    await manager.done()
